const initState = () => {
    return {
        isLogin: false,
        userName: '',
        passWord: '',
        themeColor: {},

    };
};
const state = initState();
const getters = {
    userName(state) {
        return state.userName;
    },
    passWord(state) {
        return state.passWord;
    },
    isLogin(state) {
        return state.isLogin
    },
    themeColor(state) {
        return state.themeColor
    },

};
const mutations = {
    setUserName(state, value) {
        state.userName = value;
    },
    setPassWord(state, value) {
        state.passWord = value;
    },
    setLogin(state, value) {
        state.isLogin = value;
        uni.setStorageSync('isLogin', value);
    },
    setThemeColor(state, value) {
        state.themeColor = value
    },

    // 用于退出登录统一重置数据
    resetState(state) {
        Object.assign(state, initState());
    }
};
const actions = {
    setUserName({ commit }, value) {
        commit('setUserName', value);
    },
    setPassWord({ commit }, value) {
        commit('setPassWord', value);
    },
    setLogin({ commit }, value) {
        commit('setLogin', value)
    },

};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};